package com.shuai.model.converter;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.shuai.model.po.SysUser;
import com.shuai.model.vo.SysUserVo;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import java.util.List;

/**
 * 用户信息转换器
 *
 * @author shuai
 * @since 2022
 */
@Slf4j
public class SysUserConverter {
    /**
     * Po转换Vo
     * @param source
     * @return
     */
    public static SysUserVo convertToVoByPo(SysUser source) {
        SysUserVo target = new SysUserVo();
        BeanUtil.copyProperties(source, target);
        return target;
    }

    /**
     * Po转换Vo
     * @param sources
     * @return
     */
    public static List<SysUserVo> convertToVoByPo(List<SysUser> sources) {
        List<SysUserVo> newList = CollUtil.newArrayList();
        sources.stream().forEach(item->{
            SysUserVo target = new SysUserVo();
            BeanUtil.copyProperties(item, target);
            newList.add(target);
        });
        return newList;
    }
}
